<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title th:text="${article.name}+'--Java源码分享网'"></title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="description" th:content="${article.description}+'_Java资源分享网,java周边技术资源视频免费下载网站,一个java程序员都知道的分享网站'" />
    <meta name="keywords" th:content="${article.keywords}+',java下载,java资源分享网,Java源码分享网'" />
    <link rel="shortcut icon" href="/static/foreground/images/logomin.png" type="image/x-icon" />
    <link rel="stylesheet" href="/static/foreground/layui/css/layui.css">
    <link rel="stylesheet" href="/static/foreground/css/global.css">
	<script src="/static/js/jquery-1.8.3.min.js"></script>
	<!--<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>-->
	<!--<script>-->
	  <!--(adsbygoogle = window.adsbygoogle || []).push({-->
		<!--google_ad_client: "ca-pub-6607902665870473",-->
		<!--enable_page_level_ads: true-->
	  <!--});-->
	<!--</script>-->
	
	<script>
	(function(){
		var bp = document.createElement('script');
		var curProtocol = window.location.protocol.split(':')[0];
		if (curProtocol === 'https') {
			bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
		}
		else {
			bp.src = 'http://push.zhanzhang.baidu.com/push.js';
		}
		var s = document.getElementsByTagName("script")[0];
		s.parentNode.insertBefore(bp, s);
	})();
	</script>
	
	<script>
	var _hmt = _hmt || [];
	(function() {
	  var hm = document.createElement("script");
	  hm.src = "https://hm.baidu.com/hm.js?8bf19f58afd0d97855b0bbc3a1463e70";
	  var s = document.getElementsByTagName("script")[0]; 
	  s.parentNode.insertBefore(hm, s);
	})();
	</script>


</head>
<body>

<div th:replace="common/header::#h"></div>

<div class="fly-panel fly-column" style="height: auto">
    <div class="layui-container">
        <ul class="layui-clear" th:utext="${arcTypeStr}">
        </ul>
    </div>
</div>

<div class="layui-container">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md8">
            <div class="fly-panel detail-box">
                <h1 th:text="${article.name}"></h1>
                <div class="fly-detail-info">
                    <span th:if="${article.hot == true}" class="layui-badge layui-bg-red">热门</span>
                    <span class="layui-badge layui-bg-green fly-detail-column"  th:text="${#dates.format(article.publishDate, 'yyyy-MM-dd')}">发布时间</span>
                    <span class="layui-badge layui-bg-black" th:text="${article.arcType.arcTypeName}">资源类别</span>
                    <span class="layui-badge layui-bg-black" th:if="${article.free == true}">免费资源</span>
                    <span class="fly-list-nums">

                    <i class="iconfont" title="点击">&#xe60b;</i> <span th:text="${article.click}"></span>

          </span>
                </div>
                <div th:if="${article.useful == true}" style="text-align: center;margin-bottom: 10px;" class="layui-hide-sm">
                    <button class="layui-btn layui-btn-radius layui-btn-warm" onclick="download()">&nbsp;&nbsp;立即下载&nbsp;&nbsp;</button>
                    <button class="layui-btn layui-btn-radius" onclick="vipDownload()" style="background-color: red">&nbsp;&nbsp;VIP免积分下载&nbsp;&nbsp;</button>
                </div>
                <div th:if="${article.useful == false}" style="text-align: center;" class="layui-hide-sm">
                    <font color="red">该资源链接已失效，暂时无法提供下载。</font>
                </div>
                <div class="detail-about">
                    <a class="fly-avatar">
                        <img th:src="'/static/img/' + ${article.user.headPortrait}" th:alt="${article.user.nickname}">
                    </a>
                    <div th:if="${article.useful == true}" style="float: right;" class="layui-hide-xs">
                        <button class="layui-btn layui-btn-radius layui-btn-warm" onclick="download()">&nbsp;&nbsp;立即下载&nbsp;&nbsp;</button>
                        <button class="layui-btn layui-btn-radius" onclick="vipDownload()" style="background-color: red">&nbsp;&nbsp;VIP免积分下载&nbsp;&nbsp;</button>
                    </div>
                    <div th:if="${article.useful == false}" style="float: right;" class="layui-hide-xs">
                        <font color="red">该资源链接已失效，暂时无法提供下载。</font>
                    </div>
                    <div class="fly-detail-user">
                        <a class="fly-link">
                            <cite th:text="${article.user.nickname}">作者</cite>
                            <i th:if="${article.user.vip == true}" class="iconfont icon-renzheng" title="会员认证"></i>
                            <i th:if="${article.user.vip == true}" class="layui-badge fly-badge-vip" th:text="'VIP' + ${article.user.vipGrade}">VIP</i>
                        </a>
                        <span th:text="${#dates.format(article.publishDate, 'yyyy-MM-dd HH:mm')}">2018-9-15</span>
                    </div>
                    <div class="detail-hits" id="LAY_jieAdmin" data-id="123">
                        <span style="padding-right: 10px; color: #FF7200" th:text="'所需：' + ${article.points} + '积分'"></span>
                    </div>


                </div>
                <div class="detail-body photos" th:utext="${article.content}">
                </div>
            </div>

            <div class="fly-panel detail-box" id="flyReply">
                <fieldset class="layui-elem-field layui-field-title" style="text-align: center;">
                    <legend>评论</legend>
                </fieldset>

                <div class="layui-form layui-form-pane">
                    <form action="/jie/reply/" method="post">
                        <div class="layui-form-item layui-form-text">
                            <a name="comment"></a>
                            <div class="layui-input-block">
                                <textarea id="L_content" name="content" placeholder="请输入内容" class="layui-textarea fly-editor"></textarea>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <button class="layui-btn" lay-filter="addComment" lay-submit>提交评论</button>
                        </div>
                    </form>
                </div>

                <ul class="jieda" id="jieda">

                </ul>


            </div>
        </div>

        <div class="layui-col-md4">

                <dl class="fly-panel fly-list-one">
                <dt class="fly-panel-title">下载排行</dt>
                <dd th:each="article : ${application.clickArticle}">
                    <a th:href="@{'/article/detail/'+${article.articleId}+'.html'}" target="_blank" th:text="${article.name}"></a>
                    <span><i class="iconfont" title="人气">&#xe60b;</i> <span th:text="${article.click}"></span></span>
                </dd>

                <!-- 无数据时 -->
                <!--
                <div class="fly-none">没有相关数据</div>
                -->
            </dl>
			

            <dl class="fly-panel fly-list-one">
                <dt class="fly-panel-title">热搜推荐</dt>
                <dd th:each="article : ${application.randomArticle}">
                    <a th:href="@{'/article/detail/'+${article.articleId}+'.html'}" target="_blank" th:text="${article.name}"></a>
                    <span><i class="iconfont" title="人气">&#xe60b;</i> <span th:text="${article.click}"></span></span>
                </dd>

                <!-- 无数据时 -->
                <!--
                <div class="fly-none">没有相关数据</div>
                -->
            </dl>

            <dl class="fly-panel fly-list-one">
                <dt class="fly-panel-title">相似资源</dt>
                <dd th:each="article : ${similarityArticleList}">
                    <a th:href="@{'/article/detail/'+${article.articleId}+'.html'}" target="_blank" th:text="${article.name}"></a>
                    <span><i class="iconfont" title="人气">&#xe60b;</i> <span th:text="${article.click}"></span></span>
                </dd>
                <div th:if="${similarityArticleList == null}" class="fly-none">没有相关数据</div>
            </dl>
			
			<!--<div class="fly-panel">-->
                <!--<div class="fly-panel-title">-->
                    <!--广告赞助-->
                <!--</div>-->
                <!--<div class="fly-panel-main">-->
					<!--&lt;!&ndash; 详情右边广告 &ndash;&gt;-->
					<!--<ins class="adsbygoogle"-->
						 <!--style="display:block"-->
						 <!--data-ad-client="ca-pub-6607902665870473"-->
						 <!--data-ad-slot="1022701898"-->
						 <!--data-ad-format="auto"-->
						 <!--data-full-width-responsive="true"></ins>-->
					<!--<script>-->
					<!--(adsbygoogle = window.adsbygoogle || []).push({});-->
					<!--</script>-->
                <!--</div>-->
            <!--</div>-->

        </div>
    </div>
</div>

<div th:replace="common/footer.html::#f"></div>


<script src="/static/foreground/layui/layui.all.js"></script>
<script src="/static/js/index.js"></script>
<script th:inline="javascript">
    /*<![CDATA[*/

        layui.use(['flow','layedit','form'], function(){
            var flow = layui.flow
                ,layedit = layui.layedit
                ,form = layui.form
                ,$ = layui.jquery;

            //构建一个自定义编辑器
            var index = layedit.build('L_content', {
                height: 150 //设置编辑器高度
                ,tool: ['strong' //加粗
                    ,'italic' //斜体
                    ,'underline' //下划线
                    ,'del' //删除线

                    ,'|' //分割线

                    ,'left' //左对齐
                    ,'center' //居中对齐
                    ,'right' //右对齐
                    ,'link' //超链接
                    ,'unlink' //清除链接
                    ,'face' //表情
                ]
            });

            form.on('submit(addComment)', function(data){
                //console.log(data.elem) //被执行事件的元素DOM对象，一般为button对象
                //console.log(data.form) //被执行提交的form对象，一般在存在form标签时才会返回
                //console.log(data.field) //当前容器的全部表单字段，名值对形式：{name: value}
                if([[${session.currentUser}]]==null){
                    layer.msg("登录后才能评论！");
                    return false;
                }

                // 判断是否下载过
                // 添加记录
                $.post("/user/userDownloadExist",{"articleId":[[${article.articleId}]]},function(result){
                    if(result){ // 下载过
                        var content=$.trim(layedit.getText(index));
                        if(content==""){
                            layer.msg("请输入评论信息！");
                            return false;
                        }
                        $.post("/comment/add",{"article.articleId":[[${article.articleId}]],"content":content},function(result){
                            if(result.success){
                                layer.msg('评论成功，审核后显示！', {
                                    icon: 1,
                                    time: 1000 //2秒关闭（如果不配置，默认是3秒）
                                }, function(){
                                    layedit.setContent(index,'');
                                });
                            }
                        },"json");

                    }else{  // 未下载过
                        layer.msg("下载该资源后才能评论！");
                    }
                },"json");

                return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
            });



            //评论显示
            flow.load({
                elem: '#jieda' //流加载容器
                ,done: function(page, next){ //执行下一页的回调
                    setTimeout(function(){
                        $.post("/comment/list",{"page":page,"article.articleId":[[${article.articleId}]]}, function(res) {
                            //执行下一页渲染，第二参数为：满足“加载更多”的条件，即后面仍有分页
                            //pages为Ajax返回的总页数，只有当前页小于总页数的情况下，才会继续出现加载更多
                            next(res.data, page < res.total);
                        }, "json");
                    }, 500);
                }
            });
        });


    function vipDownload(){
        // 判断是否登录
        if([[${session.currentUser}]]==null){
            layer.msg("登录后才能下载资源！");
            return;
        }

        $.post("/user/isVip",{},function(result){
            if(result){

                // 判断是否下载过
                // 添加记录
                $.post("/user/userDownloadExist",{"articleId":[[${article.articleId}]]},function(result){
                    if(result){ // 下载过
                        layer.confirm('该资您已经下载过,您确定要下载这个资源吗？', {
                            title:"下载提示"
                            ,btn: ['确定','取消'] //按钮
                        }, function(){
                            layer.closeAll('dialog');
                            layer.open({
                                type: 2,
                                title: '资源下载页面',
                                shadeClose: true,
                                shade: 0.8,
                                area: ['480px', '200px'],
                                content: '/user/toVipDownLoadPage/[[${article.articleId}]]' //iframe的url
                            });
                        }, function(){

                        });
                    }else{  // 未下载过
                        layer.confirm('您确定要下载这个资源吗？', {
                            title:"下载提示"
                            ,btn: ['确定','取消'] //按钮
                        }, function(){
                            layer.closeAll('dialog');
                            layer.open({
                                type: 2,
                                title: '资源下载页面',
                                shadeClose: true,
                                shade: 0.8,
                                area: ['480px', '200px'],
                                content: '/user/toVipDownLoadPage/[[${article.articleId}]]' //iframe的url
                            });

                        }, function(){

                        });

                    }
                },"json");


            }else{
                layer.msg("您不是VIP用户，不能使用此通道下载！");
            }
        },"json");
    }

    function download(){

        // 判断是否登录
        if([[${session.currentUser}]]==null){
            layer.msg("登录后才能下载资源！");
            return;
        }

        // 判断是否下载过
        // 添加记录
        $.post("/user/userDownloadExist",{"articleId":[[${article.articleId}]]},function(result){
            if(result){ // 下载过
                layer.confirm('该资您已经下载过，再下载不需要扣除积分,您确定要下载这个资源吗？', {
                    title:"下载提示"
                    ,btn: ['确定','取消'] //按钮
                }, function(){
                    layer.closeAll('dialog');
                    layer.open({
                        type: 2,
                        title: '资源下载页面',
                        shadeClose: true,
                        shade: 0.8,
                        area: ['480px', '200px'],
                        content: '/user/toDownLoadPage/[[${article.articleId}]]' //iframe的url
                    });
                }, function(){

                });
            }else{  // 未下载过

                    //是否免费资源
                    $.post("/article/isFree",{"articleId":[[${article.articleId}]]},function(result){
                       if(result){  // 免费资源
                           layer.confirm('确定要 <font color="red">免费</font>下载这个资源吗？', {
                               title:"下载提示"
                               ,btn: ['确定','取消'] //按钮
                           }, function(){
                               layer.closeAll('dialog');
                               layer.open({
                                   type: 2,
                                   title: '资源下载页面',
                                   shadeClose: true,
                                   shade: 0.8,
                                   area: ['480px', '200px'],
                                   content: '/user/toDownLoadPage/[[${article.articleId}]]' //iframe的url
                               });

                           }, function(){

                           });

                       } else{
                           // 添加记录
                           $.post("/user/userDownloadEnough",{"points":[[${article.points}]]},function(result){
                               if(result){  // 积分足够
                                   layer.confirm('该资源下载需要 <font color="red">[[${article.points}]]</font> 积分,您确定要下载这个资源吗？', {
                                       title:"下载提示"
                                       ,btn: ['确定','取消'] //按钮
                                   }, function(){
                                       layer.closeAll('dialog');
                                       layer.open({
                                           type: 2,
                                           title: '资源下载页面',
                                           shadeClose: true,
                                           shade: 0.8,
                                           area: ['480px', '200px'],
                                           content: '/user/toDownLoadPage/[[${article.articleId}]]' //iframe的url
                                       });

                                   }, function(){

                                   });

                               }else{ // 积分不够
                                   layer.msg("您的积分不够，不能下载该资源！");
                                   return;
                               }
                                 },"json");
                        }
                    },"json");
                }
                });
    }

    /*]]>*/
</script>

</body>
</html>